package com.ruoyi.adapayDiv.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.adapayDiv.domain.AdapayDiv;
import com.ruoyi.adapayDiv.service.IAdapayDivService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分账记录支付确认记录Controller
 *
 * @author ch
 * @date 2022-02-28
 */
@RestController
@RequestMapping("/adapayDiv/adapayDiv")
public class AdapayDivController extends BaseController
{
    @Autowired
    private IAdapayDivService adapayDivService;

    /**
     * 查询分账记录支付确认记录列表
     */
    @PreAuthorize("@ss.hasPermi('adapayDiv:adapayDiv:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdapayDiv adapayDiv)
    {
        startPage();
        List<AdapayDiv> list = adapayDivService.selectAdapayDivList(adapayDiv);
        return getDataTable(list);
    }

    /**
     * 导出分账记录支付确认记录列表
     */
    @PreAuthorize("@ss.hasPermi('adapayDiv:adapayDiv:export')")
    @Log(title = "分账记录支付确认记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdapayDiv adapayDiv)
    {
        List<AdapayDiv> list = adapayDivService.selectAdapayDivList(adapayDiv);
        ExcelUtil<AdapayDiv> util = new ExcelUtil<AdapayDiv>(AdapayDiv.class);
        return util.exportExcel(list, "分账记录支付确认记录数据");
    }

    /**
     * 获取分账记录支付确认记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('adapayDiv:adapayDiv:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adapayDivService.selectAdapayDivById(id));
    }

    /**
     * 新增分账记录支付确认记录
     */
    @PreAuthorize("@ss.hasPermi('adapayDiv:adapayDiv:add')")
    @Log(title = "分账记录支付确认记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdapayDiv adapayDiv)
    {
        return toAjax(adapayDivService.insertAdapayDiv(adapayDiv));
    }

    /**
     * 修改分账记录支付确认记录
     */
    @PreAuthorize("@ss.hasPermi('adapayDiv:adapayDiv:edit')")
    @Log(title = "分账记录支付确认记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdapayDiv adapayDiv)
    {
        adapayDiv.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(adapayDivService.updateAdapayDiv(adapayDiv));
    }

    /**
     * 删除分账记录支付确认记录
     */
    @PreAuthorize("@ss.hasPermi('adapayDiv:adapayDiv:remove')")
    @Log(title = "分账记录支付确认记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adapayDivService.logicDeleteAdapayDiv(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
